<article class="" id="post-">
<header class="entry-header">
<h1 class="entry-title">callbacks.disable()</h1>
<div class="entry-meta">
						所属分类：<span class="category"><a href="/category/callbacks-object/">回调对象</a></span>
<span class="pull-right">英文文档：<a href="https://api.jquery123.com/callbacks.disable/" target="_blank">callbacks.disable()</a></span>
</div><!-- .entry-meta -->
</header><!-- .entry-header -->
<!-- .entry-header -->
<div class="entry-content">
<article class="entry method" id="callbacks-disable1"><h2 class="section-title">
<span class="name">callbacks.disable()</span><span class="returns">返回: <a href="/Types/#Callbacks">Callbacks</a></span>
</h2>
<div class="entry-wrapper">
<p class="desc"><strong>描述: </strong>禁用回调列表中的回调</p>
<ul class="signatures"><li class="signature" id="callbacks-disable">
<h4 class="name">
<span class="version-details">添加的版本: <a href="/category/version/1.7/">1.7</a></span>callbacks.disable()</h4>
<ul><li><div class="null-signature">这个方法不接受任何参数</div></li></ul>
</li></ul>
<div class="longdesc" id="entry-longdesc">
<p>此方法返回绑定它的那个回调对象(<code>this</code>).</p>
<h2 id="example-1">Example</h2>
<p>使用 <code>callbacks.disable()</code> 禁止回调列表中的回调进一步的调用:</p>
<div class="syntaxhighlighter javascript nogutter">
<table>
<tbody>
<tr>
<td class="gutter">
<div class="line n1">1</div>
<div class="line n2">2</div>
<div class="line n3">3</div>
<div class="line n4">4</div>
<div class="line n5">5</div>
<div class="line n6">6</div>
<div class="line n7">7</div>
<div class="line n8">8</div>
<div class="line n9">9</div>
<div class="line n10">10</div>
<div class="line n11">11</div>
<div class="line n12">12</div>
<div class="line n13">13</div>
<div class="line n14">14</div>
<div class="line n15">15</div>
<div class="line n16">16</div>
<div class="line n17">17</div>
<div class="line n18">18</div>
<div class="line n19">19</div>
<div class="line n20">20</div>
</td>
<td class="code">
<pre><div class="container"><div class="line"><code><span class="comment">// a sample logging function to be added to a callbacks list</span></code></div></div><div class="container"><div class="line"><code><span class="keyword">var</span> foo = <span class="keyword">function</span>( value ) {</code></div></div><div class="container"><div class="line"><code>  console.log( value );</code></div></div><div class="container"><div class="line"><code>};</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="keyword">var</span> callbacks = $.Callbacks();</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// add the above function to the list</span></code></div></div><div class="container"><div class="line"><code>callbacks.add( foo );</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// fire the items on the list</span></code></div></div><div class="container"><div class="line"><code>callbacks.fire( <span class="string">"foo"</span> );</code></div></div><div class="container"><div class="line"><code><span class="comment">// outputs: foo</span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// disable further calls being possible</span></code></div></div><div class="container"><div class="line"><code>callbacks.disable();</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// attempt to fire with "foobar" as an argument</span></code></div></div><div class="container"><div class="line"><code>callbacks.fire( <span class="string">"foobar"</span> );</code></div></div><div class="container"><div class="line"><code><span class="comment">// foobar isn't output</span></code></div></div></pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div></article> </div>
</article>